home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / netscape / applet / AppletClassLoader.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  13.2 KB  |  824 lines

  1. package netscape.applet;
  2.  
  3. import java.io.ByteArrayInputStream;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. import java.io.InputStream;
  9. import java.net.MalformedURLException;
  10. import java.net.URL;
  11. import java.net.URLConnection;
  12. import java.util.Enumeration;
  13. import java.util.Hashtable;
  14. import java.util.Vector;
  15. import java.util.zip.ZipEntry;
  16. import java.util.zip.ZipFile;
  17. import netscape.misc.WeakLink;
  18. import netscape.security.AppletSecurity;
  19. import netscape.security.AppletSecurityException;
  20. import netscape.security.Principal;
  21. import netscape.security.PrivilegeManager;
  22. import netscape.security.Target;
  23.  
  24. public class AppletClassLoader extends ClassLoader {
  25.    URL codeBaseURL;
  26.    URL archiveURL;
  27.    MozillaAppletContext context;
  28.    static boolean wantTiming;
  29.    long loaderTime;
  30.    String scriptOrigin;
  31.    boolean isReusable;
  32.    Principal codeBasePrincipal;
  33.    Principal[] matchPrincipalAry;
  34.    public static final String MANIFEST_FILENAME = "META-INF/manifest.mf";
  35.    private String archiveFile;
  36.    private boolean capturedArchive;
  37.    private int nativeArchive;
  38.    private int nativeZig;
  39.    byte[] inputBuf;
  40.    static Vector classloaders = new Vector(10);
  41.    private static boolean capturingClasses;
  42.    private static final boolean MARIMBA_ENABLED = true;
  43.    private CastanetChannelInfo channelInfo;
  44.    private Hashtable codebaseEnv;
  45.  
  46.    String grabArchiveFile() throws IOException {
  47.       String var1 = this.archiveURL.getFile();
  48.       if (!var1.endsWith(".jar") && !var1.endsWith(".zip")) {
  49.          return null;
  50.       } else {
  51.          String var2;
  52.          if (capturingClasses) {
  53.             int var3 = var1.lastIndexOf(47);
  54.             String var4 = var1.substring(var3 + 1);
  55.             var2 = this.getCaptureDir() + "/" + var4;
  56.          } else {
  57.             var2 = this.getTempName();
  58.             if (var2 == null) {
  59.                return null;
  60.             }
  61.          }
  62.  
  63.          SecurityManager.enablePrivilege("UniversalFileAccess");
  64.          SecurityManager.enablePrivilege("UniversalConnect");
  65.          FileOutputStream var14 = new FileOutputStream(var2);
  66.          long var15 = 0L;
  67.          if (wantTiming) {
  68.             var15 = System.currentTimeMillis();
  69.          }
  70.  
  71.          InputStream var6 = null;
  72.  
  73.          try {
  74.             URLConnection var9 = this.archiveURL.openConnection();
  75.             var9.setAllowUserInteraction(false);
  76.             var6 = var9.getInputStream();
  77.             if (this.inputBuf == null) {
  78.                this.inputBuf = new byte[4096];
  79.             }
  80.  
  81.             Thread var11 = Thread.currentThread();
  82.  
  83.             int var10;
  84.             while((var10 = var6.read(this.inputBuf)) >= 0 && !var11.isInterrupted()) {
  85.                var14.write(this.inputBuf, 0, var10);
  86.             }
  87.  
  88.             if (var11.isInterrupted()) {
  89.                throw new IOException("interrupted: " + this);
  90.             }
  91.          } finally {
  92.             if (var6 != null) {
  93.                var6.close();
  94.             }
  95.  
  96.             if (var14 != null) {
  97.                var14.close();
  98.             }
  99.  
  100.          }
  101.  
  102.          SecurityManager.revertPrivilege();
  103.          if (wantTiming) {
  104.             long var7 = System.currentTimeMillis();
  105.             long var16 = var7 - var15;
  106.             this.loaderTime += var16;
  107.             System.err.println("# Archive download time: " + this.archiveURL + ": " + var16 + " (total = " + this.loaderTime + ")");
  108.          }
  109.  
  110.          if (capturingClasses) {
  111.             System.err.println("#\tCaptured archive " + var2);
  112.             this.capturedArchive = true;
  113.          } else if (this.context != null && MozillaAppletContext.debug >= 2) {
  114.             System.err.println("# Loading classes from downloaded archive file: " + this.archiveURL);
  115.          }
  116.  
  117.          return var2;
  118.       }
  119.    }
  120.  
  121.    native String getTempName();
  122.  
  123.    private native int openArchive0(String var1) throws IOException;
  124.  
  125.    private native byte[] loadFromArchive0(int var1, String var2) throws IOException;
  126.  
  127.    private native void closeArchive0(int var1) throws IOException;
  128.  
  129.    void openArchive() {
  130.       try {
  131.          this.archiveFile = this.grabArchiveFile();
  132.          if (this.archiveFile == null) {
  133.             return;
  134.          }
  135.  
  136.          this.nativeArchive = this.openArchive0(this.archiveFile);
  137.          if (this.nativeArchive != 0) {
  138.             this.nativeZig = this.setupZignature();
  139.             if (this.nativeZig != 0) {
  140.                if (!this.loadManifest(this.nativeArchive, this.nativeZig, this.codeBaseURL.getFile()) || this.loadSignatures(this.nativeArchive, this.nativeZig, this.codeBaseURL.getFile()) <= 0) {
  141.                   this.nativeZig = 0;
  142.                }
  143.  
  144.                return;
  145.             }
  146.          }
  147.       } catch (IOException var2) {
  148.          ((Throwable)var2).printStackTrace();
  149.          System.err.println("# Unable to load archive " + this.archiveURL + ": " + var2);
  150.          this.nativeZig = 0;
  151.       }
  152.  
  153.    }
  154.  
  155.    byte[] loadFromArchive(String var1) throws IOException {
  156.       return this.nativeArchive != 0 ? this.loadFromArchive0(this.nativeArchive, var1) : null;
  157.    }
  158.  
  159.    void closeArchive() {
  160.       if (this.nativeArchive != 0) {
  161.          try {
  162.             this.closeArchive0(this.nativeArchive);
  163.             if (this.context != null && MozillaAppletContext.debug >= 5) {
  164.                System.err.println("# Closed downloaded archive: " + this.archiveURL);
  165.             }
  166.          } catch (IOException var3) {
  167.             if (this.context != null && MozillaAppletContext.debug >= 5) {
  168.                System.err.println("# Failed to close downloaded archive: " + this.archiveURL);
  169.             }
  170.          }
  171.  
  172.          this.nativeArchive = 0;
  173.          if (!this.capturedArchive) {
  174.             File var1 = new File(this.archiveFile);
  175.             SecurityManager.enablePrivilege("UniversalFileRead");
  176.             SecurityManager.enablePrivilege("UniversalFileDelete");
  177.             boolean var2 = var1.delete();
  178.             SecurityManager.revertPrivilege();
  179.             if (this.context != null && MozillaAppletContext.debug >= 5) {
  180.                if (var2) {
  181.                   System.err.println("# Deleted downloaded archive: " + this.archiveFile);
  182.                   return;
  183.                }
  184.  
  185.                System.err.println("# Failed to delete downloaded archive: " + this.archiveFile);
  186.             }
  187.          }
  188.       }
  189.  
  190.    }
  191.  
  192.    static synchronized AppletClassLoader getClassLoader(MozillaAppletContext var0, URL var1, URL var2, String var3, boolean var4) {
  193.       boolean var5 = false;
  194.       AppletClassLoader var6 = null;
  195.       SecurityManager.enablePrivilege("UniversalConnect");
  196.  
  197.       for(int var8 = 0; var8 < classloaders.size(); ++var8) {
  198.          WeakLink var9 = (WeakLink)classloaders.elementAt(var8);
  199.          AppletClassLoader var10 = (AppletClassLoader)var9.get();
  200.          if (var10 == null) {
  201.             var5 = true;
  202.          } else {
  203.             String var11 = var1.getFile();
  204.             int var12 = var11.lastIndexOf(47);
  205.             URL var7 = var1;
  206.             if (var12 > 0 && var12 < var11.length() - 1) {
  207.                try {
  208.                   var7 = new URL(var1, var11.substring(0, var12 + 1));
  209.                } catch (MalformedURLException var13) {
  210.                }
  211.             }
  212.  
  213.             if (var7.equals(var10.codeBaseURL)) {
  214.                label89: {
  215.                   boolean var10000;
  216.                   if (var2 == null) {
  217.                      if (var10.archiveURL == null) {
  218.                         break label89;
  219.                      }
  220.  
  221.                      var10000 = false;
  222.                   } else {
  223.                      var10000 = var2.equals(var10.archiveURL);
  224.                   }
  225.  
  226.                   if (!var10000) {
  227.                      continue;
  228.                   }
  229.                }
  230.  
  231.                label81: {
  232.                   boolean var16;
  233.                   if (var3 == null) {
  234.                      if (var10.scriptOrigin == null) {
  235.                         break label81;
  236.                      }
  237.  
  238.                      var16 = false;
  239.                   } else {
  240.                      var16 = var3.equals(var10.scriptOrigin);
  241.                   }
  242.  
  243.                   if (!var16) {
  244.                      continue;
  245.                   }
  246.                }
  247.  
  248.                if ((var3 == null || var0 == var10.context) && var10.isReusable) {
  249.                   if (!var4) {
  250.                      var6 = var10;
  251.                      if (MozillaAppletContext.debug >= 8) {
  252.                         System.err.println("#   reusing class loader " + var10 + "\n" + "#\tcontext = " + var0 + "\n" + "#\tcodebase = " + var7 + "\n" + "#\tarchive = " + var2 + "\n" + "#\tscriptOrigin = " + var3);
  253.                      }
  254.                      break;
  255.                   }
  256.  
  257.                   if (MozillaAppletContext.debug >= 8) {
  258.                      System.err.println("#   preventing reuse of " + var10);
  259.                   }
  260.  
  261.                   var10.isReusable = false;
  262.                }
  263.             }
  264.          }
  265.       }
  266.  
  267.       SecurityManager.revertPrivilege();
  268.       if (var6 == null) {
  269.          var6 = new AppletClassLoader(var0, var1, var2);
  270.          var6.scriptOrigin = var3;
  271.          classloaders.addElement(new WeakLink(var6));
  272.       }
  273.  
  274.       if (var5) {
  275.          for(int var14 = classloaders.size() - 1; var14 >= 0; --var14) {
  276.             WeakLink var15 = (WeakLink)classloaders.elementAt(var14);
  277.             if (var15.get() == null) {
  278.                classloaders.removeElementAt(var14);
  279.             }
  280.  
  281.             if (MozillaAppletContext.debug >= 8) {
  282.                System.err.println("#   classloader was removed");
  283.             }
  284.          }
  285.       }
  286.  
  287.       return var6;
  288.    }
  289.  
  290.    AppletClassLoader(MozillaAppletContext var1, URL var2, URL var3) {
  291.       this.capturedArchive = false;
  292.       this.scriptOrigin = null;
  293.       this.isReusable = true;
  294.       this.codeBasePrincipal = new Principal(var2);
  295.       String var4 = var2.getFile();
  296.       int var5 = var4.lastIndexOf(47);
  297.       if (var5 > 0 && var5 < var4.length() - 1) {
  298.          try {
  299.             var2 = new URL(var2, var4.substring(0, var5 + 1));
  300.          } catch (MalformedURLException var6) {
  301.          }
  302.       }
  303.  
  304.       this.codeBaseURL = var2;
  305.       this.archiveURL = var3;
  306.       this.context = var1;
  307.       if (MozillaAppletContext.debug > 5) {
  308.          System.err.println("#   new class loader " + this + "\n" + "#\tcontext = " + var1 + "\n" + "#\tcodebase = " + var2 + "\n" + "#\tarchive = " + var3);
  309.       }
  310.  
  311.       if (this.archiveURL != null) {
  312.          this.openArchive();
  313.       }
  314.  
  315.    }
  316.  
  317.    void close() {
  318.       if (this.archiveURL != null) {
  319.          this.closeArchive();
  320.       }
  321.  
  322.       if (this.channelInfo != null) {
  323.          this.channelInfo.closeZips();
  324.       }
  325.  
  326.    }
  327.  
  328.    protected void finalize() {
  329.       this.close();
  330.       if (MozillaAppletContext.debug >= 8) {
  331.          System.err.println("# finalized: " + this);
  332.       }
  333.  
  334.    }
  335.  
  336.    protected AppletClassLoader(URL var1) {
  337.       this((MozillaAppletContext)null, var1, (URL)null);
  338.    }
  339.  
  340.    String getScriptOrigin() {
  341.       return this.scriptOrigin;
  342.    }
  343.  
  344.    public URL getCodeBase() {
  345.       return this.codeBaseURL;
  346.    }
  347.  
  348.    private Class loadClass(String var1, URL var2, String var3) throws IOException {
  349.       SecurityManager.enablePrivilege("UniversalConnect");
  350.       byte[] var4 = var2.getData();
  351.       SecurityManager.revertPrivilege();
  352.       if (capturingClasses) {
  353.          this.captureClassFile(var1, var4);
  354.       }
  355.  
  356.       return ((ClassLoader)this).defineClass(var1, var4, 0, var4.length, this.nativeZig, var3);
  357.    }
  358.  
  359.    public Class loadClass(String var1) throws ClassNotFoundException {
  360.       return this.loadClass(var1, true);
  361.    }
  362.  
  363.    protected final Class loadClass(String var1, boolean var2) throws ClassNotFoundException {
  364.       Class var3;
  365.       if (wantTiming) {
  366.          long var4 = System.currentTimeMillis();
  367.          var3 = this.loadClass1(var1, var2);
  368.          long var6 = System.currentTimeMillis();
  369.          long var8 = var6 - var4;
  370.          this.loaderTime += var8;
  371.          System.err.println("# Class load time: " + var1 + ": " + var8 + " (total = " + this.loaderTime + ")");
  372.       } else {
  373.          var3 = this.loadClass1(var1, var2);
  374.       }
  375.  
  376.       return var3;
  377.    }
  378.  
  379.    private Class loadClass1(String var1, boolean var2) throws ClassNotFoundException {
  380.       Class var3 = ((ClassLoader)this).findLoadedClass(var1);
  381.       if (var3 == null) {
  382.          SecurityManager var4 = System.getSecurityManager();
  383.          if (var4 != null) {
  384.             int var5 = var1.lastIndexOf(46);
  385.             if (var5 >= 0) {
  386.                var4.checkPackageAccess(var1.substring(0, var5));
  387.             }
  388.          }
  389.  
  390.          try {
  391.             return ((ClassLoader)this).findSystemClass(var1);
  392.          } catch (NoClassDefFoundError var8) {
  393.             if (this.channelInfo == null) {
  394.                throw var8;
  395.             }
  396.          } catch (ClassNotFoundException var9) {
  397.          }
  398.  
  399.          var3 = this.findClass(var1);
  400.       }
  401.  
  402.       if (var3 == null) {
  403.          throw new ClassNotFoundException(var1);
  404.       } else {
  405.          if (this.nativeArchive != 0) {
  406.             System.getSecurityManager().checkURLConnect(this.codeBaseURL, this.archiveURL);
  407.          }
  408.  
  409.          if (var2) {
  410.             try {
  411.                ((ClassLoader)this).resolveClass(var3);
  412.             } catch (NoClassDefFoundError var6) {
  413.                if (this.channelInfo == null) {
  414.                   throw var6;
  415.                }
  416.  
  417.                throw new ClassNotFoundException(var1);
  418.             } catch (UnknownError var7) {
  419.                if (this.channelInfo == null) {
  420.                   throw var7;
  421.                }
  422.  
  423.                throw new ClassNotFoundException(var1);
  424.             }
  425.          }
  426.  
  427.          return var3;
  428.       }
  429.    }
  430.  
  431.    private synchronized Class findClass(String var1) throws ClassNotFoundException {
  432.       boolean var2 = true;
  433.       Class var3 = ((ClassLoader)this).findLoadedClass(var1);
  434.       if (var3 != null) {
  435.          return var3;
  436.       } else {
  437.          if (MozillaAppletContext.debug >= 2) {
  438.             System.err.println("# Loading class " + var1);
  439.          }
  440.  
  441.          SecurityManager var4 = System.getSecurityManager();
  442.          if (var4 != null) {
  443.             int var5 = var1.lastIndexOf(46);
  444.             if (var5 >= 0) {
  445.                var4.checkPackageDefinition(var1.substring(0, var5));
  446.             }
  447.          }
  448.  
  449.          String var14 = var1.replace('.', '/') + ".class";
  450.          if (this.nativeArchive != 0) {
  451.             try {
  452.                byte[] var6 = this.loadFromArchive(var14);
  453.                if (var6 != null) {
  454.                   var3 = ((ClassLoader)this).defineClass(var1, var6, 0, var6.length, this.nativeZig, var14);
  455.                   if (var3 != null && this.context != null && MozillaAppletContext.debug >= 2) {
  456.                      System.err.println("# Loaded " + var14 + " from " + this.archiveURL);
  457.                   }
  458.  
  459.                   var2 = false;
  460.                }
  461.             } catch (IOException var12) {
  462.                if (MozillaAppletContext.debug >= 2) {
  463.                   System.err.println("# Failed to load " + var14 + " from " + this.archiveURL);
  464.                }
  465.             }
  466.          }
  467.  
  468.          if (var3 == null) {
  469.             URL var15;
  470.             try {
  471.                var15 = new URL(this.codeBaseURL, var14);
  472.             } catch (MalformedURLException var9) {
  473.                throw new ClassNotFoundException(var1);
  474.             }
  475.  
  476.             if (this.context != null && MozillaAppletContext.debug >= 5) {
  477.                System.err.println("# Fetching " + var15);
  478.             }
  479.  
  480.             try {
  481.                var3 = this.loadClass(var1, var15, var14);
  482.                var2 = false;
  483.             } catch (IOException var10) {
  484.                if (this.channelInfo != null) {
  485.                   try {
  486.                      var3 = this.marimbaLoad(var1);
  487.                      var2 = false;
  488.                   } catch (IOException var8) {
  489.                   }
  490.                }
  491.  
  492.                if (var3 == null) {
  493.                   throw new ClassNotFoundException(var1);
  494.                }
  495.             } catch (SecurityException var11) {
  496.                if (this.context != null && MozillaAppletContext.debug >= 5) {
  497.                   System.err.println("# Exception while loading " + var14 + " from downloaded archive " + var15.toString() + "\n#   Exception: " + ((Throwable)var11).toString());
  498.                }
  499.  
  500.                throw var11;
  501.             }
  502.          }
  503.  
  504.          if (!var1.equals(var3.getName())) {
  505.             Class var16 = var3;
  506.             Object var13 = null;
  507.             throw new ClassFormatError(var1 + " != " + var16.getName());
  508.          } else {
  509.             if (!var2) {
  510.                this.setPrincipalAry(var3, var14);
  511.             }
  512.  
  513.             return var3;
  514.          }
  515.       }
  516.    }
  517.  
  518.    static boolean getCaptureClassFiles() {
  519.       return capturingClasses;
  520.    }
  521.  
  522.    static void setCaptureClassFiles(boolean var0) {
  523.       capturingClasses = var0;
  524.    }
  525.  
  526.    String getCaptureDir() throws IOException {
  527.       String var1 = this.codeBaseURL.toString();
  528.       if (var1.startsWith("http://")) {
  529.          var1 = var1.substring(7);
  530.       }
  531.  
  532.       if (var1.endsWith("/")) {
  533.          var1 = var1.substring(0, var1.length() - 1);
  534.       }
  535.  
  536.       var1 = var1.replace('/', '_').replace(':', '_');
  537.       SecurityManager.enablePrivilege("UniversalFileRead");
  538.       SecurityManager.enablePrivilege("UniversalFileWrite");
  539.       File var2 = new File(var1);
  540.       if ((!var2.exists() || !var2.isDirectory()) && !var2.mkdir()) {
  541.          throw new IOException(var2 + " is not a directory");
  542.       } else {
  543.          return var1;
  544.       }
  545.    }
  546.  
  547.    void captureClassFile(String var1, byte[] var2) {
  548.       try {
  549.          String var3 = this.getCaptureDir();
  550.          SecurityManager.enablePrivilege("UniversalFileRead");
  551.          SecurityManager.enablePrivilege("UniversalFileWrite");
  552.  
  553.          File var6;
  554.          do {
  555.             int var4 = var1.indexOf(46);
  556.             if (var4 == -1) {
  557.                File var9 = new File(var3 + "/" + var1 + ".class");
  558.                FileOutputStream var10 = new FileOutputStream(var9);
  559.                var10.write(var2, 0, var2.length);
  560.                System.err.println("#\tCaptured class " + var9);
  561.                var10.close();
  562.                return;
  563.             }
  564.  
  565.             String var5 = var1.substring(0, var4);
  566.             var1 = var1.substring(var4 + 1);
  567.             var3 = var3 + "/" + var5;
  568.             var6 = new File(var3);
  569.          } while(var6.exists() && var6.isDirectory() || var6.mkdir());
  570.  
  571.          throw new IOException("Can't create " + var6);
  572.       } catch (SecurityException var7) {
  573.          System.err.println("#\tCan't capture class: " + var7);
  574.       } catch (IOException var8) {
  575.          System.err.println("#\tCan't capture class: " + var8);
  576.       }
  577.    }
  578.  
  579.    byte[] getResource(URL var1) {
  580.       byte[] var2 = null;
  581.       String var3 = var1.getFile();
  582.       String var4 = this.codeBaseURL.getFile();
  583.       if (!var3.startsWith(var4)) {
  584.          return null;
  585.       } else {
  586.          String var5 = var3.substring(var4.length());
  587.  
  588.          try {
  589.             var2 = this.loadFromArchive(var5);
  590.             if (var2 != null && this.context != null && MozillaAppletContext.debug >= 5) {
  591.                System.err.println("# Loaded " + var5 + " from " + this.archiveURL);
  592.             }
  593.  
  594.             if (var2 == null && this.context != null && MozillaAppletContext.debug >= 5) {
  595.                System.err.println("# " + var5 + " in " + this.archiveURL + " not found.");
  596.             }
  597.          } catch (IOException var6) {
  598.             if (MozillaAppletContext.debug >= 5) {
  599.                System.err.println("# Failed to load " + var5 + " from " + this.archiveURL);
  600.             }
  601.          }
  602.  
  603.          return var2;
  604.       }
  605.    }
  606.  
  607.    public InputStream getResourceAsStream(String var1) {
  608.       System.getSecurityManager().checkResourceAccess(var1);
  609.       Object var2 = null;
  610.  
  611.       try {
  612.          URL var5 = new URL(this.codeBaseURL, var1);
  613.          byte[] var3 = this.getResource(var5);
  614.          return var3 == null ? null : new ByteArrayInputStream(var3);
  615.       } catch (MalformedURLException var4) {
  616.          return null;
  617.       }
  618.    }
  619.  
  620.    private boolean setPrincipalAry(Class var1, String var2) {
  621.       Object var3 = null;
  622.       int var4 = 1;
  623.       Object[] var5 = getCertificates(this.nativeZig, var1, var2);
  624.       if (var5 != null) {
  625.          var4 += var5.length;
  626.       }
  627.  
  628.       Principal[] var12 = new Principal[var4];
  629.  
  630.       for(int var6 = var4 - 1; var6-- > 0; var12[var6] = new Principal(14, (byte[])var5[var6], var1)) {
  631.       }
  632.  
  633.       var12[var4 - 1] = this.codeBasePrincipal;
  634.  
  635.       try {
  636.          if (this.matchPrincipalAry != null) {
  637.             PrivilegeManager var9 = AppletSecurity.getPrivilegeManager();
  638.             if (var9 != null && var9.comparePrincipalArray(var12, this.matchPrincipalAry) == 1) {
  639.                var12 = new Principal[]{this.codeBasePrincipal};
  640.                throw new AppletSecurityException("mismatch of principals");
  641.             }
  642.          }
  643.       } finally {
  644.          this.setPrincipals(var1, var12);
  645.       }
  646.  
  647.       return true;
  648.    }
  649.  
  650.    public boolean checkMatchPrincipalAlways(int var1) {
  651.       PrivilegeManager var5 = AppletSecurity.getPrivilegeManager();
  652.       if (var5 == null) {
  653.          return true;
  654.       } else {
  655.          this.matchPrincipalAry = var5.getClassPrincipalsFromStack(var1 + 1);
  656.          Enumeration var2 = ((ClassLoader)this).getClassNames();
  657.  
  658.          while(var2.hasMoreElements()) {
  659.             String var4 = (String)var2.nextElement();
  660.             Class var3 = ((ClassLoader)this).findLoadedClass(var4);
  661.             if (var3 != null && !var5.checkMatchPrincipal(var3, var1 + 1)) {
  662.                return false;
  663.             }
  664.          }
  665.  
  666.          return true;
  667.       }
  668.    }
  669.  
  670.    private native int setupZignature();
  671.  
  672.    private native int destroyZignature(int var1);
  673.  
  674.    private native boolean loadManifest(int var1, int var2, String var3);
  675.  
  676.    private native int loadSignatures(int var1, int var2, String var3);
  677.  
  678.    private native boolean verifySignature(int var1, Class var2, String var3);
  679.  
  680.    private static native Object[] getCertificates(int var0, Class var1, String var2);
  681.  
  682.    private native void setPrincipals(Class var1, Principal[] var2);
  683.  
  684.    public AppletClassLoader(URL var1, CastanetChannelInfo var2) {
  685.       this((MozillaAppletContext)null, var1, (URL)null);
  686.       this.channelInfo = var2;
  687.    }
  688.  
  689.    public Class classFromBytes(byte[] var1, String var2) {
  690.       if (this.channelInfo == null) {
  691.          return null;
  692.       } else {
  693.          Class var3 = ((ClassLoader)this).findLoadedClass(var2);
  694.          if (var3 != null) {
  695.             return var3;
  696.          } else {
  697.             try {
  698.                var3 = ((ClassLoader)this).findSystemClass(var2);
  699.                if (var3 != null) {
  700.                   return var3;
  701.                }
  702.             } catch (NoClassDefFoundError var8) {
  703.             } catch (ClassNotFoundException var9) {
  704.             }
  705.  
  706.             SecurityManager var4 = System.getSecurityManager();
  707.             if (var4 != null) {
  708.                int var5 = var2.lastIndexOf(46);
  709.                if (var5 >= 0) {
  710.                   var4.checkPackageDefinition(var2.substring(0, var5));
  711.                }
  712.             }
  713.  
  714.             PrivilegeManager var12 = PrivilegeManager.getPrivilegeManager();
  715.             if (var12 != null) {
  716.                Target var6 = Target.findTarget("MarimbaInternalTarget");
  717.                if (var6 == null) {
  718.                   throw new AppletSecurityException("classFromBytes call denied");
  719.                }
  720.  
  721.                var12.checkPrivilegeEnabled(var6);
  722.             }
  723.  
  724.             try {
  725.                var3 = ((ClassLoader)this).defineClass(var2, var1, 0, var1.length);
  726.                return var3;
  727.             } catch (NoClassDefFoundError var7) {
  728.                return null;
  729.             }
  730.          }
  731.       }
  732.    }
  733.  
  734.    private Class marimbaLoad(String var1) throws IOException, ClassNotFoundException {
  735.       if (this.channelInfo == null) {
  736.          return null;
  737.       } else {
  738.          Class var2 = null;
  739.          int var3 = this.channelInfo.getPathlen();
  740.          if (var3 != 0) {
  741.             String var4 = var1.replace('.', '/') + ".class";
  742.  
  743.             for(int var5 = 0; var5 < var3; ++var5) {
  744.                URL var6 = this.channelInfo.getURL(var5);
  745.                if (var6 != null) {
  746.                   try {
  747.                      var2 = this.loadClass(var1, new URL(var6, var4), var4);
  748.                      if (var2 != null) {
  749.                         return var2;
  750.                      }
  751.                   } catch (NoClassDefFoundError var14) {
  752.                   } catch (MalformedURLException var15) {
  753.                   } catch (FileNotFoundException var16) {
  754.                   }
  755.                }
  756.  
  757.                ZipFile var7 = this.channelInfo.getZip(var5);
  758.                if (var7 != null) {
  759.                   ZipEntry var8 = var7.getEntry(var4);
  760.                   if (var8 != null) {
  761.                      int var9 = (int)var8.getSize();
  762.                      byte[] var10 = new byte[var9];
  763.                      InputStream var11 = var7.getInputStream(var8);
  764.  
  765.                      for(int var12 = 0; var12 < var9; var12 += var11.read(var10, var12, var9 - var12)) {
  766.                      }
  767.  
  768.                      var11.close();
  769.  
  770.                      try {
  771.                         var2 = ((ClassLoader)this).defineClass(var1, var10, 0, var10.length);
  772.                      } catch (NoClassDefFoundError var13) {
  773.                      }
  774.  
  775.                      if (var2 != null) {
  776.                         return var2;
  777.                      }
  778.                   }
  779.                }
  780.             }
  781.          }
  782.  
  783.          return null;
  784.       }
  785.    }
  786.  
  787.    public boolean marimbaCheckRead(String var1, boolean var2) {
  788.       return this.channelInfo != null ? this.channelInfo.checkRead(var1, var2) : false;
  789.    }
  790.  
  791.    public boolean marimbaCheckWrite(String var1, boolean var2) {
  792.       return this.channelInfo != null ? this.channelInfo.checkWrite(var1, var2) : false;
  793.    }
  794.  
  795.    public String marimbaGetHost() {
  796.       return this.channelInfo != null ? this.channelInfo.getHost() : null;
  797.    }
  798.  
  799.    boolean marimbaCheckThreadGroup(ThreadGroup var1) {
  800.       return this.channelInfo == null ? false : this.channelInfo.checkThreadGroup(var1);
  801.    }
  802.  
  803.    void marimbaCheckTopLevelWindow(Object var1) {
  804.       if (this.channelInfo != null) {
  805.          this.channelInfo.checkTopLevelWindow(var1);
  806.       }
  807.    }
  808.  
  809.    Hashtable getCodebaseEnv() {
  810.       if (this.codebaseEnv == null) {
  811.          this.initCodebaseEnv();
  812.       }
  813.  
  814.       return this.codebaseEnv;
  815.    }
  816.  
  817.    synchronized void initCodebaseEnv() {
  818.       if (this.codebaseEnv == null) {
  819.          this.codebaseEnv = new Hashtable();
  820.       }
  821.  
  822.    }
  823. }
  824.